#pragma once
#include <iostream>
#include <pthread.h>
#include <semaphore.h>
namespace SemMoudle
{
    const int as = 1;
    class Sem
    {
    public:
        Sem(size_t s = as)
        {
            sem_init(&_s,0,s);
        }
        void P()
        {
            int n=sem_wait(&_s);//信号量--
            (void)n;
        }
        void V()
        {
            int n=sem_post(&_s);//信号量++
            (void)n;
        }
        ~Sem()
        {
        }

    private:
        sem_t _s;
    };
}